package net.sansi.v3correctserver.config;


import net.sansi.v3correctserver.service.websocket.updateprogress.UpdateProgressWSHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

import javax.annotation.Resource;

/**
 * Created by Fang
 * create time : 2025/2/17
 * IDE : IntelliJ IDEA
 */

@Configuration
@EnableWebSocket
public class CusWebsocketConfiguration implements WebSocketConfigurer {

    @Resource
    private UpdateProgressWSHandler updateProgressWSHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        // 更新任务进度
        registry.addHandler(updateProgressWSHandler, "/task/progress/update")
                .setAllowedOrigins("*");
    }
}
